<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>

<style>

table label.error {
    margin-left: 5px;
    width: auto;
    display: inline;
    color: red;
}
</style>

</head>
<body>
     <form action="#" name="Form" id="Form" method="post">
        <input type="hidden" name="xmid" id="xmid"  value="${data.xmid}"/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="95%">
			<tr>
				<td class="table-header" colspan="4">材料项目信息</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%"><font style="color: red;">*</font>材料项目名称：</td>
				<td class="table-contentTD" style="width: 35%">
				<input type="text" id="xmmc" name="xmmc"  placeholder="材料项目名称" value="${data.xmmc}"  autocomplete="off" maxlength="100" class="required  inputText" /></td>
		
			 <td class="table-titleTD" style="width: 15%"><font style="color: red;">*</font>排序次序：</td>
			    <td class="table-contentTD">
				<input type="number" name="orders" id="orders" placeholder="排序次序"  value="${data.orders}"    autocomplete="off"  class="required inputText"  /></td>
			</tr>
			
			<tr>
				<td class="table-titleTD" style="width: 15%">项目状态：</td>
				<td class="table-contentTD">
					   <input type="radio" value="1" name="states" <c:if test="${data.states=='true'}">checked="checked"</c:if>/>有效
					   <input type="radio" value="0" name="states" <c:if test="${data.states=='false'}">checked="checked"</c:if>/>无效
				</td>
			
				<td class="table-titleTD" style="width: 15%">提交期限：</td>
				<td class="table-contentTD">
				<input name="deadline1" id="deadline1" placeholder="提交期限"   autocomplete="off" value="${data.deadline1}"
									class="Wdate inputText2 text" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"/></td>
			</tr>
			
		     <tr>
				<td class="table-titleTD" style="width: 15%">发布状态:</td>
				<td class="table-contentTD">
					  <input type="radio" value="1" name="issued" <c:if test="${data.issued=='true'}">checked="checked"</c:if>/>已发布
					  <input type="radio" value="0" name="issued" <c:if test="${data.issued=='false'}">checked="checked"</c:if>/>未发布
				</td>
				<td class="table-titleTD" style="width: 15%">发布时间:</td>
				<td class="table-contentTD">
				<input name="issuetime1" id="issuetime1" placeholder="发布时间"   autocomplete="off"  value="${data.issuetime1}"
									class="Wdate inputText2  text" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"/></td>
			</tr>
			
			
			<tr>
			
			<td class="table-titleTD">备注:</td>
				<td class="table-contentTD" colspan="3"><textarea style="width: 90%;height: 80px;" name="remark"  
				placeholder="备注" id="remark" maxlength="2000" >${data.remark}</textarea></td>
			</tr>
			
		</table>
		<br />

		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<c:if test="${_login_user_type==2}">
			<tr>
			    <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"XGGL_BJXX_BJCL\")%>" key="modify">			
			    <td><input type="button" id="btnSave" class="inputButton" style="text-align: center;" value="保存" /></td>
			    </kl:permission>
				<td><input type="button" id="Cancel" class="inputButton" style="text-align: center;" value="取消" /></td>
				<td><input type="button" id="returnBut" class="inputButton" value="返回" style="text-align: center;" /></td>
			</tr>
			</c:if>
		</table>
		
		<script>
			$(document).ready(function() {
				var _form=$("#Form").validate();
				$("#btnSave").click(function() {
					if(_form.form()){
						var addressID = $("input[name='issued']:checked").val();
						if(addressID==0){
							var issuetime1=$("#issuetime1").val();
							
							if(issuetime1!=''){
								     layer.alert('未发布时不能填写发布时间', {icon: 5});
								     return false;
							}
						}
					   validateObj();
					}
				});
				
				
				
				
				$("#Cancel").click(function() {
					  window.location.href ="${basePath}/bjxxClassMaterialProject/details?id="+ $("#xmid").val();
		 		});
				
				$("#returnBut").click(function() {
		 			 window.location.href='${basePath}/bjxxClassMaterialProject/index';
		 		});
			});
			
			function validateObj(){
			  	$.ajax({
					  type: 'POST',
					  url: "${basePath}/bjxxClassMaterialProject/validation",
				      data:{xmmc : $('#xmmc').val(),id:$('#xmid').val()},
				      dataType:"json",
					  success:function(data){
					   if(data.msg=="-99"){
						     layer.alert('服务器异常', {icon: 5});
						     return false;
					   }else if(data.msg!='0'){
						     layer.alert('项目名称已经存在请重新输入', {icon: 5});
						     return false;
					   }else{
						    document.Form.action ="${basePath}/bjxxClassMaterialProject/update";
							document.Form.submit();
					   }   
					  }
					});	
			}
		</script>
	</form>
</body>
</html>
